package com.sfh.alliance.home;

import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sfh.alliance.AnimaUtil;
import com.sfh.alliance.R;

/**
 * 功能描述:
 *
 * @date 2017/9/5
 */
public class PersonView extends LinearLayout {

    ImageView iv_type;

    TextView tv_content;

    ImageView iv_person;

    LinearLayout ly;

    public PersonView(Context context) {

        super (context);
        init();
    }

    public PersonView(Context context, @Nullable AttributeSet attrs) {

        super (context, attrs);
        init();
    }

    public PersonView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {

        super (context, attrs, defStyleAttr);
        init();
    }


    private void init() {
        //
        this.inflate (getContext (), R.layout.main_person_layout, this);

        iv_type = $ (R.id.iv_type);
        tv_content = $ (R.id.tv_content);
        iv_person = $ (R.id.iv_person);
        ly = $ (R.id.ly);
        AnimaUtil.geTranslateAnimation (ly);
    }

    public void setData(int type,String content,int person){
        iv_type.setImageResource (type);
        tv_content.setText (content);
        iv_person.setImageResource (person);
    }
    private <T extends View> T $(@IdRes int resId) {

        return (T) super.findViewById (resId);
    }
}
